
<!DOCTYPE html>
<html lang="">


<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
  <meta name="theme-color" content="#202020">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <script src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>
  
  
    <meta name="keywords" content="oh-my-zsh,">
  

  
    <meta name="description" content="Oh-my-zsh">
  
  
  <link rel="icon" type="image/x-icon" href="/logo.png">
  <title>Oh-my-zsh [ 复制粘贴工程师 ]</title>
  
    <!-- stylesheets list from config.yml -->
    
      <link rel="stylesheet" href="//cdn.bootcss.com/pure/1.0.0/pure-min.css">
    
      <link rel="stylesheet" href="/css/xoxo.css">
    
  
</head>


<body>
  <div class="nav-container">
    <nav class="home-menu pure-menu pure-menu-horizontal">
  <a class="pure-menu-heading" href="/">
    <img class="avatar" src="https://wx.qlogo.cn/mmopen/vi_32/AMpRacDgkTPogKk4gQ5IC3QezP55XoPpicQpnD9Vz3eNz6OPFYyFrFzCa4EGQGH65kPia5YJwQBBvvJpVwQ4lfVg/132">
    <span class="title">复制粘贴工程师</span>
  </a>

  <ul class="pure-menu-list clearfix">
      
          
            <li class="pure-menu-item"><a href="/" class="pure-menu-link">首页</a></li>
          
      
          
            <li class="pure-menu-item"><a href="/search" class="pure-menu-link">搜索</a></li>
          
      
  </ul>

</nav>
  </div>

  <div class="container" id="content-outer">
    <div class="inner" id="content-inner">
      <div class="post-container">
  <article class="post" id="post">
    <header class="post-header text-center">
      <h1 class="title">
        Oh-my-zsh
      </h1>
      <span>
        
        <time class="time" datetime="2019-02-28T06:33:56.000Z">
        2019-02-28
      </time>
        
      </span>
      <span class="slash">/</span>
      <span class="post-meta">
      <span class="post-tags">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/oh-my-zsh/">oh-my-zsh</a></li></ul>
      </span>
    </span>
      <span class="slash">/</span>
      <span class="read">
      <span id="busuanzi_value_page_pv"></span> 点击
    </span>
      <span class="slash">/</span>
    </header>

    <div class="post-content">
      <p><code>zsh</code> 是一个虚拟终端，原先不同的终端有不同的命令，现在通过这个虚拟终端就可以执行所有的命令，如可以执行git命令、subline命令等。本文将介绍 <code>zsh</code> 在 <code>mac</code> 中的安装和使用。</p>
<a id="more"></a>
<h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 安装</span></span><br><span class="line">1. curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh</span><br><span class="line"></span><br><span class="line"><span class="comment"># 创建配置文件</span></span><br><span class="line">2. cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc</span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置zsh为默认终端</span></span><br><span class="line">3. chsh -s /bin/zsh</span><br><span class="line"></span><br><span class="line"><span class="comment"># 安装完成后会自带一些主题，也可以去下面的地址下载主题放到 ~/.oh-my-zsh/themes 下</span></span><br><span class="line">4. https://github.com/robbyrussell/oh-my-zsh/wiki/themes</span><br></pre></td></tr></table></figure>
<h3 id="修改主题"><a href="#修改主题" class="headerlink" title="修改主题"></a>修改主题</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> 打开配置文件：open ~<span class="regexp">/.zshrc</span></span><br><span class="line"><span class="regexp">2. 修改配置文件：ZSH_THEME=你想要的主题，默认为robbyrussell</span></span><br><span class="line"><span class="regexp">3. 让配置文件生效：source ~/</span>.zshrc</span><br><span class="line"><span class="number">4.</span> 主题推荐：ys，ys是安装时自带的，无需额外下载</span><br></pre></td></tr></table></figure>
<h3 id="自动补全插件-incr"><a href="#自动补全插件-incr" class="headerlink" title="自动补全插件 incr"></a>自动补全插件 <code>incr</code></h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">1. 下载：http://mimosa-pudica.net/zsh-incremental.html</span><br><span class="line">2. 进入plugins文件夹：cd ~/.oh-my-zsh/plugins</span><br><span class="line">3. 创建一个新的文件夹并进入：mkdir incr; cd incr</span><br><span class="line">4. 创建一个新的文件：touch incr-0.2.zsh</span><br><span class="line">5. 把下载下来的文件拷贝过来：cp /Users/jasper/Downloads/incr-0.2.zsh incr-0.2.zsh</span><br><span class="line">6. 赋予该文件最高权限：chmod 777 ~/.oh-my-zsh/plugins/incr/incr-0.2.zsh</span><br><span class="line">7. 在./zshrc中加入这样一句话：source ~/.oh-my-zsh/plugins/incr/incr-0.2.zsh</span><br><span class="line">8. 让配置文件生效：source ~/.zshrc</span><br><span class="line">9. 配置完成，现在已经有自动补全了</span><br></pre></td></tr></table></figure>
<h3 id="路径跳转插件autojump"><a href="#路径跳转插件autojump" class="headerlink" title="路径跳转插件autojump"></a>路径跳转插件autojump</h3><blockquote>
<p>其实用到的频率并不高，如果命令行卡的话不建议安装</p>
</blockquote>
<p>只要你访问过某路径如/a/b/c/d，那么下次你输入j d就可以快速进入该路径<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">1. 找个地方准备下载如Downloads：git clone git://github.com/joelthelion/autojump.git</span><br><span class="line">2. 进入autojump文件夹：cd autojump</span><br><span class="line">3. 运行安装文件：./install.py</span><br><span class="line">4. 根据提示，将下面的命令复制到~/.zshrc中</span><br></pre></td></tr></table></figure></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[[ -s /Users/jasper/.autojump/etc/profile.d/autojump.sh ]] &amp;&amp; source /Users/jasper/.autojump/etc/profile.d/autojump.sh</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">5. 更新配置： source ~/.zshrc</span><br><span class="line">6. 安装完成</span><br></pre></td></tr></table></figure>
<h3 id="代码高亮插件zsh-syntax-highlighting"><a href="#代码高亮插件zsh-syntax-highlighting" class="headerlink" title="代码高亮插件zsh-syntax-highlighting"></a>代码高亮插件zsh-syntax-highlighting</h3><p><code>zsh-syntax-highlighting</code> 可以高亮一些常用命令如<code>cd</code>、<code>open</code>等<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">1. 下载插件： git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $&#123;ZSH_CUSTOM:-~/.oh-my-zsh/custom&#125;/plugins/zsh-syntax-highlighting</span><br><span class="line">2. 在.zshrc的plugins中添加zsh-syntax-highlighting，plugins=&#123;... zsh-syntax-highlighting&#125;</span><br></pre></td></tr></table></figure></p>
<h3 id="不用安装的插件"><a href="#不用安装的插件" class="headerlink" title="不用安装的插件"></a>不用安装的插件</h3><p>这些插件只需要在 <code>.zshrc</code> 的 <code>plugins</code> 里面添加即可，如 <code>plugins={git web-search}</code>，添加后需要重启终端</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">1. web-search: 可以快速进行搜索，如google test或者baidu test，就会打开浏览器并进行搜索</span><br><span class="line">2. last-working-dir：打开终端的默认路径为上一次离开时的路径（推荐）</span><br><span class="line">3. wd: 可以给目录添加索引，进入/a/b/c/d然后执行wd add test，之后无论在哪里执行wd test都会进入到/a/b/c/d</span><br></pre></td></tr></table></figure>
    </div>

    <div>全文完。</div>
  </article>
  <div class="toc-container">
    
  <div id="toc" class="toc-article">
    <strong class="toc-title">目录</strong>
    <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#安装"><span class="toc-text">安装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#修改主题"><span class="toc-text">修改主题</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#自动补全插件-incr"><span class="toc-text">自动补全插件 incr</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#路径跳转插件autojump"><span class="toc-text">路径跳转插件autojump</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#代码高亮插件zsh-syntax-highlighting"><span class="toc-text">代码高亮插件zsh-syntax-highlighting</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#不用安装的插件"><span class="toc-text">不用安装的插件</span></a></li></ol>
  </div>


  </div>
</div>
<div class="copyright">
    <span>本作品采用</span>
    <a href="https://creativecommons.org/licenses/by/4.0/">知识共享署名 4.0 国际许可协议</a>
    <span>进行许可。 转载时请注明原文链接。</span>
</div>
<div class="share" style="width: 100%;">
  <!-- <img src="https://kevinofneu-blog-static.oss-cn-beijing.aliyuncs.com/static/2018-12-10-qrcode_for_gh_ffacf5722095_258.jpg" alt="Running Geek" style="margin: auto; display: block;"/>

  <div style="margin: auto; text-align: center; font-size: 0.8em; color: grey;">老铁们关注走一走，不迷路</div> -->

</div>

  
    <div class="post-nav">
      <div class="post-nav-item post-nav-next">
        
          <span>〈 </span>
          <a href="/2019/02/28/Github小白指南/" rel="next" title="Github小白指南">
          Github小白指南
          </a>
        
      </div>
  
      <div class="post-nav-item post-nav-prev">
          
          <a href="/2019/02/28/Javascript代码检查那点事/" rel="prev" title="Javascript代码检查那点事">
            Javascript代码检查那点事
          </a>
          <span>〉</span>
        
      </div>
    </div>
  


    </div>

    
    <div id="vcomments" style="max-width: 800px; margin: 16px auto;"></div>
  </div>
  <footer class="footer text-center">
    <div id="bottom-inner">
        <a class="bottom-item" href="/">首页</a> |
        <a class="bottom-item" href="https://github.com/TJ-XiaJiaHao" target="_blank">GitHub</a> |
        <a class="bottom-item">联系邮箱：1452806@tongji.edu.cn</a>
    </div>
</footer>
  

<script>
  (function(window, document, undefined) {

    var timer = null;

    function returnTop() {
      cancelAnimationFrame(timer);
      timer = requestAnimationFrame(function fn() {
        var oTop = document.body.scrollTop || document.documentElement.scrollTop;
        if (oTop > 0) {
          document.body.scrollTop = document.documentElement.scrollTop = oTop - 50;
          timer = requestAnimationFrame(fn);
        } else {
          cancelAnimationFrame(timer);
        }
      });
    }

    var hearts = [];
    window.requestAnimationFrame = (function() {
      return window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.oRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        function(callback) {
          setTimeout(callback, 1000 / 60);
        }
    })();
    init();

    function init() {
      css(".heart{z-index:9999;width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: absolute;}.heart:after{top: -5px;}.heart:before{left: -5px;}");
      attachEvent();
      gameloop();
      addMenuEvent();
    }

    function gameloop() {
      for (var i = 0; i < hearts.length; i++) {
        if (hearts[i].alpha <= 0) {
          document.body.removeChild(hearts[i].el);
          hearts.splice(i, 1);
          continue;
        }
        hearts[i].y--;
        hearts[i].scale += 0.004;
        hearts[i].alpha -= 0.013;
        hearts[i].el.style.cssText = "left:" + hearts[i].x + "px;top:" + hearts[i].y + "px;opacity:" + hearts[i].alpha + ";transform:scale(" + hearts[i].scale + "," + hearts[i].scale + ") rotate(45deg);background:" + hearts[i].color;
      }
      requestAnimationFrame(gameloop);
    }

    /**
     * 给logo设置点击事件
     * 
     * - 回到顶部
     * - 出现爱心
     */
    function attachEvent() {
      var old = typeof window.onclick === "function" && window.onclick;
      var logo = document.getElementById("logo");
      if (logo) {
        logo.onclick = function(event) {
          returnTop();
          old && old();
          createHeart(event);
        }
      }
      
    }

    function createHeart(event) {
      var d = document.createElement("div");
      d.className = "heart";
      hearts.push({
        el: d,
        x: event.clientX - 5,
        y: event.clientY - 5,
        scale: 1,
        alpha: 1,
        color: randomColor()
      });
      document.body.appendChild(d);
    }

    function css(css) {
      var style = document.createElement("style");
      style.type = "text/css";
      try {
        style.appendChild(document.createTextNode(css));
      } catch (ex) {
        style.styleSheet.cssText = css;
      }
      document.getElementsByTagName('head')[0].appendChild(style);
    }

    function randomColor() {
      // return "rgb(" + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + ")";
      return "#F44336";
    }

    function addMenuEvent() {
      var menu = document.getElementById('menu-main-post');
      if (menu) {
        var toc = document.getElementById('toc');
        if (toc) {
          menu.onclick = function() {
            if (toc) {
              if (toc.style.display == 'block') {
                toc.style.display = 'none';
              } else {
                toc.style.display = 'block';
              }
            }
          };
        } else {
          menu.style.display = 'none';
        }
      }
    }

  })(window, document);
</script>

  



</body>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='//unpkg.com/valine/dist/Valine.min.js'></script>
<script type="text/javascript">
  new Valine({
    el: '#vcomments',
    appId: '8CwYqXS8IoFbvaA9PmgqGjTf-gzGzoHsz',
    appKey: 'z5bVoSPDPhd8hzlXvDey5Hpz',
    verify:false,
    placeholder: '评论留言'
  })
</script>
</html>
